<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增检核作业管理')" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-task-add">
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">作业代码：</label>
                <div class="col-sm-8">
                     <input name="taskCode" class="form-control" readonly="true" type="text" th:value="${taskCode}" required />
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">作业名称：</label>
                <div class="col-sm-8">
                    <input name="taskName" class="form-control" autocomplete="off" type="text" required />
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">检核类型：</label>
                <div class="col-sm-8">
                    <select name="verifyType" class="form-control m-b" th:with="type=${@dict.getType('verify_type')}">
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">系统代码：</label>
                <div class="col-sm-8">
                  <div class="input-group">
                         <input type="hidden" id="sysId" name="sysId" />
                     	 <input name="sysCode" onclick="selectMdSysModel()" required id="sysCode" autocomplete="off" type="text" placeholder="请选择系统" class="form-control">
                         <span class="input-group-addon"><i class="fa fa-search"></i></span>
                     </div>
                </div>
            </div>
            <div class="form-group">
				<label class="col-sm-3 control-label">系统名称：</label>
				<div class="col-sm-8">
					<input id="sysName" name="sysName" required class="form-control" readonly="true" type="text"/>
				</div>
			</div>
			 <div class="form-group">
                 <label class="col-sm-3 control-label is-required">模块代码：</label>
                 <div class="col-sm-8">
                     <div class="input-group">
                         <input type="hidden" id="moduleId" name="moduleId" />
                     	 <input name="moduleCode" required onclick="selectMdModule()" id="moduleCode" autocomplete="off" type="text" placeholder="请选择功能模块" class="form-control">
                         <span class="input-group-addon"><i class="fa fa-search"></i></span>
                     </div>
                 </div>
             </div>
			<div class="form-group">
				<label class="col-sm-3 control-label">模块名称：</label>
				<div class="col-sm-8">
					<input id="moduleName" name="moduleName" required class="form-control" readonly="true" type="text"/>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label is-required">表代码：</label>
				<div class="col-sm-8">
					<div class="input-group">
					    <input type="hidden" id="tableId" name="tableId" />
                     	<input name="tableCode" onclick="selectMdTable()" required id="tableCode" type="text" placeholder="请选择表代码" autocomplete="off" class="form-control">
                         <span class="input-group-addon"><i class="fa fa-search"></i></span>
                     </div>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">表名称：</label>
				<div class="col-sm-8">
					<input id="tableName" name="tableName" required class="form-control" readonly="true" type="text"/>
				</div>
			</div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">作业类名：</label>
                <div class="col-sm-8">
                    <input name="className" class="form-control" type="text" th:value="${className}" required />
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">类包名：</label>
                <div class="col-sm-8">
                    <input name="packageName" class="form-control" th:value="${packageName}" required type="text" />
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">作业拆分个数：</label>
                <div class="col-sm-8">
                    <input name="taskNum" class="form-control" type="text" required/>
                </div>
            </div>
             <div class="form-group">    
                <label class="col-sm-3 control-label">作业描述：</label>
                <div class="col-sm-8">
                    <input name="taskRemark" class="form-control" type="text">
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var prefix = ctx + "verify/task"
		var prefix2 = ctx + "verify/rule"
        $("#form-task-add").validate({
            focusCleanup: true,
            rules: {
            	taskName:{
					minlength: 1,
					maxlength: 20
					
				},
            	taskNum: {
    				digits: true
    			}
    		}
        });
     
        function submitHandler() {debugger;
            if ($.validate.form()) {
            	var data = $('#form-task-add').serialize();
            	//var data = $("#form-user-add").serializeArray();
            	var sysCode = $.form.selectSelects("sysCode");
                $.operate.save(prefix + "/add", data+"&sysCode="+sysCode);
            }
        }
        
    	/* 选择系统 */
        function selectMdSysModel() {debugger;
        	var url = prefix2 + "/showMdSysList";
			var options = {
				title: '选择系统',
				width: "600",
				url: url,
				callBack: doSubmitMdSysData
			};
			$.modal.openOptions(options);
		}
        function doSubmitMdSysData(index, layero){debugger;
	       var tableObj = layero.find("iframe")[0].contentWindow.$.table;
	       var sysId = tableObj.selectColumns("sysId")[0];
	       var sysCode = tableObj.selectColumns("sysCode")[0];
	       var sysName = tableObj.selectColumns("sysName")[0];
	        $("#sysId").val(sysId);
			$("#sysCode").val(sysCode);
			$("#sysName").val(sysName);
			layer.close(index);
	    }
        
        /* 选择功能模块 */
        function selectMdModule() {debugger;
        	var sysId = $("#sysId").val();
        	if($.validate.isEmpty(sysId)){
        		$.modal.alertError("系统代码不能为空!");
        		return;
        	}
        	var url = prefix2 + "/showMdModuleList/" + sysId;
			var options = {
				title: '选择功能模块',
				width: "600",
				url: url,
				callBack: doSubmitSelectModelData
			};
			$.modal.openOptions(options);
		}
		//选择表代码  
        function selectMdTable() {debugger;
	    	var moduleId = $("#moduleId").val();
	    	if($.validate.isEmpty(moduleId)){
        		$.modal.alertError("模块代码不能为空!");
        		return;
        	}
	    	var url = prefix2 + "/showMdTableList/" + moduleId;
			var options = {
				title: '选择表模块',
				width: "600",
				url: url,
				callBack: doSubmitSelectTableModeData
			};
			$.modal.openOptions(options);
		}
		
        function doSubmitSelectModelData(index, layero){debugger;
	     var tableObj = layero.find("iframe")[0].contentWindow.$.table;
	     var moduleId = tableObj.selectColumns("moduleId")[0];
	     var moduleCode = tableObj.selectColumns("moduleCode")[0];
	     var moduleName = tableObj.selectColumns("moduleName")[0];
	     $("#moduleId").val(moduleId);
			$("#moduleCode").val(moduleCode);
			$("#moduleName").val(moduleName);
			layer.close(index);
	}
	function doSubmitSelectTableModeData(index, layero){debugger;
	     var tableObj = layero.find("iframe")[0].contentWindow.$.table;
	     var tableId = tableObj.selectColumns("tableId")[0];
	     var tableCode = tableObj.selectColumns("tableCode")[0];
	     var tableName = tableObj.selectColumns("tableName")[0];
	     $("#tableId").val(tableId);
		$("#tableCode").val(tableCode);
		$("#tableName").val(tableName);
		layer.close(index);
    }
    </script>
</body>
</html>